class Money implements  Cloneable{
    public double money;
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Person implements Cloneable{
    public int id;
    public Money m = new Money();
    public Person(int id){
        this.id=id;
    }
    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", m=" + m +
                '}';
    }
    @Override
    protected Object clone() throws CloneNotSupportedException{
        Person personCopy = (Person)super.clone();
        personCopy.m=(Money)this.m.clone();
        return personCopy;
    }
}
public class TestDemo2 {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person1 = new Person(110);
        person1.m.money=100;
        System.out.println(person1);
        Person person2 = (Person)person1.clone();
        System.out.println(person2);
        person2.m.money=200;
        System.out.println(person1.m.money);
        System.out.println(person2.m.money);
    }
}
